#include "Http.hpp"
#include "TcpServer.hpp"
#include "Common.hpp"
#include <memory>

int main(int argc, char *argv[])
{
    if (argc != 2)
    {
        std::cerr << "Usage: " << argv[0] << " port" << std::endl;
        exit(USAGE_ERR);
    }
    uint16_t port = std::stoi(argv[1]);
    InetAddr addr(port);

    Http http;

    std::unique_ptr<TcpServer> httpserver = std::make_unique<TcpServer>(
        addr, [&http](std::shared_ptr<Socket> sock, const InetAddr &addr)
        { http.GetRequest(sock, addr); });

    httpserver->Start();

    return 0;
}